package com.netease.image;

import android.graphics.Bitmap;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.text.TextUtils;
import com.netease.b.a.ad;
import com.netease.b.a.b;
import com.netease.b.a.g;
import com.netease.framework.a.l;
import com.netease.pris.a.p;
import com.netease.pris.a.r;
import java.lang.ref.SoftReference;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class d
  implements com.netease.framework.b.d
{
  public static final int a = 0;
  public static final int b = 1;
  public static final int c = 2;
  static final String e = "ImageManager";
  private static d h;
  private static final int k = 1;
  private static final int l = 2;
  Handler d;
  private Map f = new HashMap();
  private HashMap g = new HashMap();
  private com.netease.framework.b.c i;
  private com.netease.framework.a.a j;

  private d()
  {
    if (Looper.myLooper() == null);
    for (this.d = new e(this, Looper.getMainLooper()); ; this.d = new e(this, Looper.myLooper()))
    {
      this.i = new com.netease.framework.b.c();
      this.j = new com.netease.framework.a.a();
      l locall = new l(this.i, this.j);
      this.i.a(locall);
      return;
    }
  }

  /** @deprecated */
  public static d a()
  {
    monitorenter;
    try
    {
      if (h == null)
        h = new d();
      d locald = h;
      monitorexit;
      return locald;
    }
    finally
    {
      localObject = finally;
      monitorexit;
    }
    throw localObject;
  }

  public static String a(String paramString, int paramInt1, int paramInt2)
  {
    if ((paramInt1 > 0) && (paramInt2 > 0))
    {
      String str1 = "";
      if ((paramInt1 > 0) && (paramInt2 > 0))
      {
        String str2 = str1 + "&w=" + paramInt1;
        str1 = str2 + "&h=" + paramInt2;
      }
      if (str1.length() > 0)
        paramString = paramString + "%local" + str1;
    }
    return paramString;
  }

  private void a(int paramInt1, int paramInt2, Object paramObject)
  {
    this.d.obtainMessage(2, paramInt1, paramInt2, paramObject).sendToTarget();
  }

  private void a(int paramInt, Object paramObject)
  {
    if (paramObject == null);
    while (true)
    {
      return;
      b localb = (b)paramObject;
      String str1 = localb.a;
      Bitmap localBitmap1 = localb.c;
      if (str1 == null)
        continue;
      List localList = b(str1.hashCode());
      if (localList == null)
        continue;
      String str2 = b(str1);
      if (localBitmap1 == null)
      {
        a(localList, str2, null);
        continue;
      }
      switch (localb.d)
      {
      default:
        break;
      case 0:
        a(localList, str2, localBitmap1);
        break;
      case 1:
        Bitmap localBitmap2 = c.b(localBitmap1);
        a(str1, localBitmap2, 1);
        a(localList, str2, localBitmap2);
        break;
      case 2:
        a(str1, localBitmap1, 2);
        a(localList, str2, localBitmap1);
      }
    }
  }

  private void a(String paramString, int paramInt1, f paramf, int paramInt2, int paramInt3, int paramInt4, int paramInt5)
  {
    g localg = g.a(paramString, true, true, paramInt1, paramInt2, paramInt3);
    localg.a(this);
    localg.b(paramInt4);
    localg.c(paramInt5);
    if ((paramInt2 > 0) && (paramInt3 > 0))
      paramString = paramString + "%local&w=" + paramInt2 + "&h=" + paramInt3;
    if (a(paramString.hashCode(), paramf))
      this.i.a(localg);
  }

  private void a(String paramString, Bitmap paramBitmap, int paramInt)
  {
    if ((paramBitmap != null) && ((paramInt == 2) || (paramInt == 1)))
    {
      Integer localInteger = Integer.valueOf(paramString.hashCode());
      this.f.put(localInteger, new SoftReference(paramBitmap));
    }
  }

  private void a(List paramList, String paramString, Bitmap paramBitmap)
  {
    Iterator localIterator = paramList.iterator();
    while (localIterator.hasNext())
      ((f)localIterator.next()).a(paramString, paramBitmap);
  }

  private Bitmap b(String paramString, int paramInt1, int paramInt2, int paramInt3)
  {
    String str1 = a(paramString);
    Bitmap localBitmap = null;
    if (!TextUtils.isEmpty(str1))
      localBitmap = p.a(str1);
    if ((localBitmap == null) && ((paramInt1 == 2) || (paramInt1 == 1)))
    {
      int m = paramString.indexOf("%local");
      if (m > 0)
      {
        String str2 = com.netease.a.a.e.a(r.a(paramString.substring(0, m)), false);
        if (str2 != null)
          localBitmap = p.a(str2);
      }
    }
    a(paramString, localBitmap, paramInt1);
    return localBitmap;
  }

  private String b(String paramString)
  {
    if (paramString == null);
    for (String str = ""; ; str = String.valueOf(paramString.hashCode()))
      return str;
  }

  public static String b(String paramString, int paramInt1, int paramInt2)
  {
    return com.netease.a.a.e.a(r.a(a(paramString, paramInt1, paramInt2)), false);
  }

  private List b(int paramInt)
  {
    Integer localInteger = Integer.valueOf(paramInt);
    synchronized (this.g)
    {
      List localList = (List)this.g.remove(localInteger);
      return localList;
    }
  }

  private void b(int paramInt, f paramf)
  {
    if (paramf == null);
    while (true)
    {
      return;
      paramf.a(String.valueOf(paramInt), null);
    }
  }

  private void c(int paramInt, f paramf)
  {
    this.d.obtainMessage(1, paramInt, 0, paramf).sendToTarget();
  }

  protected Bitmap a(String paramString, int paramInt)
  {
    SoftReference localSoftReference = (SoftReference)this.f.get(Integer.valueOf(paramString.hashCode()));
    if (localSoftReference != null);
    for (Bitmap localBitmap = (Bitmap)localSoftReference.get(); ; localBitmap = null)
      return localBitmap;
  }

  public Bitmap a(String paramString, int paramInt1, int paramInt2, int paramInt3)
  {
    if ((paramInt1 == 2) || (paramInt1 == 1))
    {
      String str = "";
      if ((paramInt2 > 0) || (paramInt3 > 0))
        str = str + "&w=" + paramInt2;
      if (paramInt3 > 0)
        str = str + "&h=" + paramInt3;
      if (str.length() > 0)
        paramString = paramString + "%local" + str;
    }
    Bitmap localBitmap = a(paramString, paramInt1);
    if (localBitmap != null);
    while (true)
    {
      return localBitmap;
      localBitmap = null;
    }
  }

  public String a(String paramString)
  {
    if (paramString == null);
    for (String str = null; ; str = com.netease.a.a.e.a(r.a(paramString), false))
      return str;
  }

  public void a(int paramInt)
  {
    if (paramInt > 0)
      this.i.b(paramInt);
  }

  public void a(int paramInt1, int paramInt2)
  {
    if (paramInt1 <= 0);
    while (true)
    {
      return;
      ad localad = ad.a(paramInt1, paramInt2);
      localad.b(4);
      this.i.a(localad);
    }
  }

  public void a(int paramInt1, int paramInt2, int paramInt3, Object paramObject)
  {
    a(paramInt3, paramInt1, paramObject);
  }

  public void a(String paramString, int paramInt1, int paramInt2, int paramInt3, int paramInt4, com.netease.framework.b.d paramd)
  {
    if (paramString == null);
    while (true)
    {
      return;
      g localg = g.a(paramString, false, false, 0, paramInt1, paramInt2);
      localg.b(paramInt3);
      localg.c(paramInt4);
      if (paramd != null)
        localg.a(paramd);
      this.i.a(localg);
    }
  }

  public void a(StringBuilder paramStringBuilder, int paramInt1, String paramString, f paramf, int paramInt2, int paramInt3)
  {
    a(paramStringBuilder, paramInt1, paramString, paramf, -1, -1, paramInt2, paramInt3);
  }

  public void a(StringBuilder paramStringBuilder, int paramInt1, String paramString, f paramf, int paramInt2, int paramInt3, int paramInt4)
  {
    a(paramStringBuilder, paramInt1, paramString, paramf, paramInt2, paramInt3, paramInt4, 0);
  }

  public void a(StringBuilder paramStringBuilder, int paramInt1, String paramString, f paramf, int paramInt2, int paramInt3, int paramInt4, int paramInt5)
  {
    a(paramStringBuilder, paramInt1, paramString, paramf, paramInt2, paramInt3, paramInt4, paramInt5, true);
  }

  public void a(StringBuilder paramStringBuilder, int paramInt1, String paramString, f paramf, int paramInt2, int paramInt3, int paramInt4, int paramInt5, boolean paramBoolean)
  {
    if (paramf == null);
    while (true)
    {
      return;
      String str1 = a(paramString, paramInt2, paramInt3);
      String str2 = b(str1);
      if (paramStringBuilder != null)
        paramStringBuilder.append(str2);
      if (TextUtils.isEmpty(paramString))
        switch (paramInt1)
        {
        default:
          break;
        case 0:
          paramf.a(str2, null);
          break;
        case 1:
          paramf.a(str2, null);
          break;
        }
      Bitmap localBitmap1 = a(str1, paramInt1);
      if (localBitmap1 != null)
        switch (paramInt1)
        {
        default:
          break;
        case 0:
          if ((paramInt2 > 0) && (paramInt3 > 0))
            paramf.a(str2, c.b(localBitmap1, paramInt2, paramInt3));
          break;
        case 1:
          paramf.a(str2, localBitmap1);
          continue;
          paramf.a(str2, localBitmap1);
          break;
        case 2:
          paramf.a(str2, localBitmap1);
          break;
        }
      if (!paramBoolean)
        localBitmap1 = b(str1, paramInt1, paramInt2, paramInt3);
      if (localBitmap1 != null)
        switch (paramInt1)
        {
        default:
          break;
        case 0:
          paramf.a(str2, localBitmap1);
          break;
        case 1:
          Bitmap localBitmap2 = c.a(localBitmap1);
          paramf.a(str2, localBitmap2);
          a(str1, localBitmap2, paramInt1);
          break;
        case 2:
          paramf.a(str2, localBitmap1);
          a(str1, localBitmap1, paramInt1);
          break;
        }
      a(paramString, paramInt1, paramf, paramInt2, paramInt3, paramInt4, paramInt5);
    }
  }

  // ERROR //
  protected boolean a(int paramInt, f paramf)
  {
    // Byte code:
    //   0: aload_2
    //   1: ifnull +112 -> 113
    //   4: iload_1
    //   5: invokestatic 189	java/lang/Integer:valueOf	(I)Ljava/lang/Integer;
    //   8: astore 4
    //   10: aload_0
    //   11: getfield 42	com/netease/image/d:g	Ljava/util/HashMap;
    //   14: astore 5
    //   16: aload 5
    //   18: monitorenter
    //   19: aload_0
    //   20: getfield 42	com/netease/image/d:g	Ljava/util/HashMap;
    //   23: aload 4
    //   25: invokevirtual 300	java/util/HashMap:get	(Ljava/lang/Object;)Ljava/lang/Object;
    //   28: checkcast 202	java/util/List
    //   31: astore 7
    //   33: aload 7
    //   35: ifnonnull +39 -> 74
    //   38: new 302	java/util/LinkedList
    //   41: dup
    //   42: invokespecial 303	java/util/LinkedList:<init>	()V
    //   45: astore 8
    //   47: aload 8
    //   49: aload_2
    //   50: invokeinterface 307 2 0
    //   55: pop
    //   56: aload_0
    //   57: getfield 42	com/netease/image/d:g	Ljava/util/HashMap;
    //   60: aload 4
    //   62: aload 8
    //   64: invokevirtual 308	java/util/HashMap:put	(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    //   67: pop
    //   68: aload 5
    //   70: monitorexit
    //   71: goto +42 -> 113
    //   74: aload 7
    //   76: aload_2
    //   77: invokeinterface 311 2 0
    //   82: ifne +23 -> 105
    //   85: aload 7
    //   87: aload_2
    //   88: invokeinterface 307 2 0
    //   93: pop
    //   94: goto -26 -> 68
    //   97: astore 6
    //   99: aload 5
    //   101: monitorexit
    //   102: aload 6
    //   104: athrow
    //   105: iconst_0
    //   106: istore_3
    //   107: aload 5
    //   109: monitorexit
    //   110: goto +5 -> 115
    //   113: iconst_1
    //   114: istore_3
    //   115: iload_3
    //   116: ireturn
    //
    // Exception table:
    //   from	to	target	type
    //   19	102	97	finally
    //   107	110	97	finally
  }

  public void b()
  {
  }

  public void b(int paramInt1, int paramInt2, int paramInt3, Object paramObject)
  {
    if (paramObject != null)
    {
      List localList = b(paramObject.hashCode());
      if (localList != null)
      {
        Iterator localIterator = localList.iterator();
        while (localIterator.hasNext())
        {
          f localf = (f)localIterator.next();
          if (!(localf instanceof a))
            continue;
          c(((String)paramObject).hashCode(), localf);
        }
      }
    }
  }

  public void c()
  {
    this.f.clear();
    if (this.i != null)
    {
      this.i.b();
      this.i = null;
    }
    if (this.j != null)
    {
      this.j.a();
      this.j = null;
    }
    h = null;
  }

  public com.netease.framework.b.c d()
  {
    return this.i;
  }

  public void e()
  {
    this.f.clear();
  }

  public void f()
  {
    g();
    this.i.d();
  }

  public void g()
  {
    synchronized (this.g)
    {
      this.g.clear();
      return;
    }
  }
}

/* Location:           D:\android\hack\dex2jar-0.0.9.8\classes_dex2jar.jar
 * Qualified Name:     com.netease.image.d
 * JD-Core Version:    0.6.0
 */